<%-- 
    Document   : ThemSanPhamContent
    Created on : Oct 23, 2011, 3:19:13 PM
    Author     : kijoo
--%>

<%@page import="MODEL.POJO.SanPhamPOJO"%>
<%@page import="MODEL.POJO.DanhMucPOJO"%>
<%@page import="MODEL.POJO.LoaiDanhMucPOJO"%>
<%@page import="MODEL.POJO.LoaiSanPhamPOJO"%>
<%@page import="MODEL.DAO.LoaiSanPhamDAO"%>
<%@page import="MODEL.DAO.LoaiDanhMucDAO"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.ArrayList"%>
<style type="text/css">
    <!--
    .style1 {color: #000000}
    -->
</style>
<script type="text/javascript" src="js/combobox2.js"></script>
<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.1.custom.min.js"></script>
<script type="text/javascript" src="js/jquery.ui.datepicker-vi.js"></script>
<link href="CSS/jquery-ui-1.8.1.custom.css" rel="stylesheet" type="text/css" />
<style type="text/css">

.formbutton{
cursor:pointer;
border:outset 1px #ccc;
background:#999;
color:#666;
font-weight:bold;
padding: 1px 2px;
background:url(images/formbg.gif) repeat-x left top;
}

</style>
<script type="text/javascript">
    $(function() {
        $.datepicker.setDefaults($.datepicker.regional['']);
        $("#ngayNhap").datepicker($.datepicker.regional['vi']);

    });
</script>

<div class="tieude">Thêm Sản Phẩm</div>
<div align="center">
    <table width="550" height="411" align="center"> 
        <form onSubmit="return kiemtra()"  action="ThemSanPhamController" method="get" name="form1" id="them">
            <!--Lay loai san pham-->
            <tr>
            <td><label><span style="color: #000000">Chọn loại sản phẩm</span></label></td>
            <td width="50%" align="left">

                <select name="loaiSP" id="loaiSP" onChange="getLoaiSPDropdown()">
                    <option value="-1" selected="selected">Chọn loại sản phẩm...</option>
                    <%
                        ArrayList<LoaiSanPhamPOJO> ds = LoaiSanPhamDAO.LayDanhSachLoaiSanPham();
                        for (int i = 0; i < ds.size(); i++) {
                            LoaiSanPhamPOJO lsp = ds.get(i);


                    %>
                    <option value="<%= lsp.getIdloaisanpham()%>" ><%= lsp.getTenloaisanpham()%></option>

                    <% }%>
                </select></td>
            </tr>
            <!--het-->

            <!--Lay loai danh muc-->

            <tr>
            <td><label><span style="color: #000000">Chọn loại danh mục</span></label></td>
            <td><div id="idloaidm"> </div></td>
            </tr>
            <!--Lay danh muc-->
            <tr>
            <td><label><span style="color: #000000">Chọn danh mục</span></label></td>
            <td><div id="loaiDanhMuc"> </div></td>
            </tr>
            <!--Lay dong san pham-->
            <tr>
            <td><label><span style="color: #000000">Chọn dòng sản phẩm</span></label></td>
            <td><div id="DanhMuc"> </div></td>
            </tr>
            
            <!--ket thuc-->
            
            <!--Nhap du lieu-->
            <tr>
            <td><label><span style="color: #000000">Mã sản phẩm</span></label></td>
            <td><label for="maSP"></label>
            <input type="text" name="maSP" id="maSP" size="40"
                   <%
                       if (request.getParameter("maSP") != null) {
                   %>
                   value="<%=request.getParameter("maSP")%>"
                   <%}%>                       />            </td>
            </tr>
            <tr>
            <td><label><span style="color: #000000">Tên sản phẩm</span></label></td>
            <td><label for="tenSP"></label>
            <input type="text" name="tenSP" id="tenSP" size="40"
                   <%
                       if (request.getParameter("tenSP") != null) {
                   %>
                   value="<%=request.getParameter("tenSP")%>"
                   <%}%>                       />            </td>
            </tr>
            <tr>
            <td><label><span style="color: #000000">Mô tả</span></label></td>
            <td><label for="moTa"></label>
            <input type="text" name="moTa" id="moTa" size="40"
                   <%
                       if (request.getParameter("moTa") != null) {
                   %>
                   value="<%=request.getParameter("moTa")%>"
                   <%}%>                       />            </td>
            </tr>
            <tr>
            <td><label><span style="color: #000000">Hình ảnh 1</span></label></td>
            <td><label for="hinh"></label>
            <input type="file" name="hinh" id="hinh" 
                   <%
                       if (request.getParameter("hinh") != null) {
                   %>
                   value="<%=request.getParameter("hinh")%>"
                   <%}%>                       />            </td>
            </tr>
            <tr>
            <td><label><span style="color: #000000">Hình ảnh 2</span></label></td>
            <td><label for="hinh2"></label>
            <input type="file" name="hinh2" id="hinh2" 
                   <%
                       if (request.getParameter("hinh2") != null) {
                   %>
                   value="<%=request.getParameter("hinh2")%>"
                   <%}%>                       />            </td>
            </tr>
            <tr>
            <td><label><span style="color: #000000">Giá bán</span></label></td>
            <td><label for="giaBan"></label>
            <input type="text" name="giaBan" id="giaBan" size="40"
                   <%
                       if (request.getParameter("giaBan") != null) {
                   %>
                   value="<%=request.getParameter("giaBan")%>"
                   <%}%>                       />            </td>
            </tr>
            <tr>
            <td><label><span style="color: #000000">Số lượng</span></label></td>
            <td><label for="soLuong"></label>
            <input type="text" name="soLuong" id="soLuong" size="40"
                   <%
                       if (request.getParameter("soLuong") != null) {
                   %>
                   value="<%=request.getParameter("soLuong")%>"
                   <%}%>                       />            </td>
            </tr>
            
            <tr>
            <td><label><span style="color: #000000">Hạn bảo hành</span></label></td>
            <td><label for="baoHanh"></label>
            <input type="text" name="baoHanh" id="baoHanh" size="40"
                   <%
                       if (request.getParameter("baoHanh") != null) {
                   %>
                   value="<%=request.getParameter("baoHanh")%>"
                   <%}%>                       />            </td>
            </tr>

            <tr>
            <td height="30"><label><span style="color: #000000">Ngày nhập</span></label></td>
            <td><label for="ngayNhap"></label>
            <input type="text" name="ngayNhap" id="ngayNhap" />         
            </td>
            </tr>
            
            <tr>
            <td height="66" colspan="2"><div align="center">
                    <p>&nbsp;                    </p>
                    <p>
                      <input  class="formbutton" type="submit" name="btThem" id="btThem" value="Thêm">
                        </p>
            </div></td>
            </tr>

        </form>
</table></div>
<script language="JavaScript">
    function kiemtra()
    {
        form1=document.getElementById("them");
        if(form1.loaiSP.value=="-1")
        {
            alert("Vui lòng chọn loại sản phẩm"); form1.loaiSP.focus(); return false; 
        }
        if(form1.maSP.value=="")
        {
            alert("Vui lòng nhập mã sản phẩm"); form1.maSP.focus(); return false; 
        }
        if(form1.tenSP.value=="")
        {
            alert("Vui lòng nhập tên sản phẩm"); form1.tenSP.focus(); return false; 
        }
        if(form1.tenSP.value=="")
        {
            alert("Vui lòng nhập tên sản phẩm"); form1.tenSP.focus(); return false; 
        }
        if(form1.moTa.value=="")
        {
            alert("Vui lòng nhập thông tin sản phẩm"); form1.moTa.focus(); return false; 
        }
        if(form1.giaBan.value=="")
        {
            alert("Vui lòng nhập giá sản phẩm"); form1.giaBan.focus(); return false; 
        }
        if(form1.soLuong.value=="")
        {
            alert("Vui lòng nhập số lượng sản phẩm"); form1.soLuong.focus(); return false; 
        }
        return true;
    }
</script> 


